class Test {
    public static void main(String[] args) {
        int[] arr = {10, 20};
        swap(arr);
        System.out.println("a = " + arr[0] + " b = " + arr[1]);
    }
    public static void swap(int[] arr) {
        int tmp = arr[0];
        arr[0] = arr[1];
        arr[1] = tmp;
    }
}
// 运行结果
a = 20 b = 10
class Test {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        swap(a, b);
        System.out.println("a = " + a + " b = " + b);
    }
    public static void swap(int x, int y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
}
// 运行结果
a = 10 b = 20
public class TestDemo14 {
    public static void main(String[] args) {
        int[] arr = {10,20};
        swap(arr);
        System.out.println("a =" + arr[0] + "b =" + arr[1]);
    }
    public static void swap(int[] arr){
        int tmp = arr[0];
        arr[0] = arr[1];
        arr[1] = tmp;
    }
    public static void main4(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 5; i++){
            sum += factor(i);
        }
        System.out.println(sum);
    }
    public static int factor(int x){
        int ret = 1;
        for (int i = 1; i <= x; i++ ){
            ret *= i;
        }
        return ret;
    }
    /*public static void main3(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 5; i++) {
            sum += factor(i);
        }
        System.out.println(sum);
    }
    public static int factor(int n){
            System.out.println("计算n的阶乘中！n=" + n);
            int result = 1;
            for (int i = 1; i <= n; i++){
                result *= i;
            }
            return result;

        }*/




    public static void main2(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("第一次调用方法之前");
        int ret = add(a,b);
        System.out.println("第一次调用方法之后");
        System.out.println("ret = " + ret);
        System.out.println("第二次调用方法之前");
        ret = add(30,50);
        System.out.println("第二次调用方法之后");
        System.out.println("ret = " + ret);
    }
    public static int add(int x, int y){
        System.out.println("调用方法中x =" + x + "y =" + y);
        return x+y;
    }


    /*public static void main(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("第一次调用方法之前");
        int ret = add(a, b);
        System.out.println("第一次调用方法之后");
        System.out.println("ret = " + ret);
        System.out.println("第二次调用方法之前");
        ret = add(30, 50);
        System.out.println("第二次调用方法之后");
        System.out.println("ret = " + ret);
    }
    public static int add(int x, int y) {
        System.out.println("调用方法中 x = " + x + " y = " + y);
        return x + y;
    }*/

    public static void main1(String[] args) {
        int a = 10;
        int b = 20;
        //方法的调用
        int ret = add(a, b);
        System.out.println(ret);
    }
        //方法的定义
    //public static int add(int x,int y){
    //        return x + y;
    //}

}
//执行结果   ret = 30
